/*********************************************************************************************************
 * begin Generic class
 ********************************************************************************************************/
function Generic(){
	this.keyVal = new Array();
}
Generic.prototype.set = function (key, val){
	this.keyVal[key] = val;
};
Generic.prototype.get = function (key){
	return this.keyVal[key]; 
};
/**
 * setNumber
 * setString
 * for fix how to decide value is number or string
 * more comfort ?
 */
/*Generic.prototype.setString = function (key, val){
    this.set(key, '' + val);
};
Generic.prototype.setNumber = function (key, val){
    this.set(key, +val);
};
*/

Generic.prototype.toJson = function (){
	this.jsonStr = '{';
	i = 0;
	for (var k in this.keyVal) {
	    if(i > 0){
	    	this.jsonStr += ',';
	    }
	    i++;
	    
	    this.val = this.keyVal[k];
	    if(typeof this.val === "number"){
	    	this.jsonStr +='"' + k + '":' + this.val + '';
	    }else if(this.val instanceof Generic){
	    	this.jsonStr +='"' + k + '":' + this.val.toJson() + '';
	    }else if(this.val instanceof Array){
	    	this.tempStr = '[';
	    	for(var j in this.val){
	    		if(j > 0){
	    			this.tempStr += ',';
	    		}
	    		var t = this.val[j];
	    		this.tempStr += '' + t.toJson();
	    	}
	    	this.tempStr += ']';
	    	
	    	this.jsonStr += '"' + k + '":' + this.tempStr;
	    }else{
	    	this.jsonStr +='"' + k + '":"' + this.val + '"';
	    }		    
	}
	this.jsonStr += '}';
	
	return this.jsonStr;
};
/*********************************************************************************************************
 * end Generic class
 ********************************************************************************************************/